<?php

    $status = (null) ? 'closed' : 'open';
    $url = 'index.php?dir=' . $dir . '&sub=' . $sub;
    
    if ($polls) {
	
	echo '<h4 class="' . $status . '" onclick="swap(this);">Polls (' . sizeof($polls) . ')</h4>';
	echo '<div>';
        echo '<table><tbody>';
        
        echo '<tr><th>#</th><th>ID</th><th>Title</th><th>Sub-Event</th><th>Options</th><th>Response Rate</th></tr>';
	
        foreach ($polls as $i=>$poll) {
            $gc = $poll->getGuestCount();
            $rd = $poll->getResponseCount();
            $rr = ($rc / $gc * 100) . '%';
            echo '<tr>';
            echo '<td>' . $i . '</td>';
            echo '<td>' . $poll->getId() . '</td>';
            echo '<td>' . $poll->getTitle() . '</td>';
            echo '<td><a href"#">' . $poll->getSubEvent() . '</a></td>';
            echo '<td>' . $poll->getOptionCount() . '</td>';
            echo '<td>' . $gc . '</td>';
            echo '<td>' . $rc . '</td>';
            echo '<td>' . $rr . '</td>';
            
            echo '</tr>';
        }
        echo '</tbody></table>';
        
    } else {
	
	echo '<h4>There are no Polls!</h4>';
	echo '<div>';

    }
    echo '</div>';
    echo '<button class="create" onclick="window.location="' . $url . '&act=edit">Add Poll</button>';
    
?>